﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Windows.Media.Imaging;
using System.ComponentModel;

namespace STEditor.Classes
{
    public class STTileImageCollection : ObservableCollection<STFrame>, INotifyPropertyChanged
    {

        private STFrame _selectedTile;
        public STFrame SelectedTile
        {
            get
            {
                return _selectedTile;
            }
            set
            {
                if (!Contains(value))
                {
                    throw new ArgumentOutOfRangeException("value", "The selected tile is not contained in the collection");
                }
                _selectedTile = value;

                OnPropertyChanged(new PropertyChangedEventArgs("SelectedTile"));
            }

        }

        public STFrame Add(string fileName)
        {

            Uri fileUri = new Uri(@"file://" + fileName);

            STFrame img = new STFrame { Source = fileUri };

            Add(img);

            return img;

        }

    }
}
